package com.resource.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.resource.project.entity.RespBean;
import com.resource.project.entity.TResource;
import com.resource.project.service.ITResourceService;
import com.resource.util.page.PageParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 物料表 前端控制器
 * </p>
 *
 * @author resource
 * @since 2020-12-08
 */
@RestController
@RequestMapping("/project/t-resource")
public class TResourceController {
    @Autowired
    private ITResourceService resourceService;
    @ApiOperation(value = "用户分页")
    @PostMapping
    public IPage<TResource> page(PageParam pageParam, @RequestBody TResource resource){
        return resourceService.page(pageParam,resource);
    }
    
    @ApiOperation(value = "添加物料")
    @PostMapping("/add")
    public RespBean add(@RequestBody TResource resource){
        return resourceService.add(resource);
    }

    @ApiOperation(value = "修改")
    @PutMapping
    public RespBean update(@RequestBody TResource resource){
        return resourceService.updateTResource(resource);
    }

    @ApiOperation(value = "获取所有物料")
    @GetMapping("/all")
    public List<TResource> all(){
        return resourceService.list();
    }
}
